import request from '@/utils/request';

// 查询用户列表
export function listUser(query) {
  return request({
    url: '/system/user/list',
    method: 'get',
    params: query
  })
}

// 查询用户详细
export function getUser(userId) {
  return request({
    url: `/system/user/${userId}`,
    method: 'get'
  })
}

// 修改用户
export function updateUser(data) {
  return request({
    url: '/system/user',
    method: 'put',
    data: data
  })
}

// 用户密码重置
export function resetUserPwd(userId) {
  return request({
    url: `/system/user/resetPwd/${userId}`,
    method: 'put'
  });
}

// 查询用户个人信息
export function getUserProfile() {
  return request({
    url: '/system/user/profile',
    method: 'get'
  })
}

// 用户密码重置
export function updateUserPwd(oldPassword, newPassword) {
  const data = {
    oldPassword,
    newPassword
  }
  return request({
    url: '/system/user/profile/updatePwd',
    method: 'put',
    params: data
  })
}

export function getUserRoles(userId) {
  return request({
    url: `/system/user/role/${userId}`,
    method: 'get'
  });
}

export function updateUserRoles(userId, data) {
  return request({
    url: `/system/user/role/${userId}`,
    method: 'put',
    data
  });
}

export function userJzList(query) {
  return request({
    url: '/system/user/jzList',
    method: 'get',
    params: query
  })
}

export function saveUserJz(data) {
  return request({
    url: '/system/user/setJz',
    method: 'post',
    data: data
  })
}
